package com.ruoyi.project.km.prettyPro.controller;

import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.km.projectManager.domain.KmPro;
import com.ruoyi.project.km.projectManager.service.ProManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("km/prettyPro")
public class PrettyProController extends BaseController {
    //声明资源访问路劲中的公共路径段
    private String prefix="km/prettyPro";

    //声明业务层属性
    @Autowired
    private ProManagerService proManagerServiceImpl;
    //声明单元方法:完成标杆项目查看页面的资源跳转
    @GetMapping("/prettyPro")
    public String prettyProPage(){
        return prefix+"/prettyPro";
    }

    //声明单元方法:加载标杆项目信息
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(KmPro kmPro)
    {
        startPage();
        kmPro.setPrettyPro(1);
        List<KmPro> list = proManagerServiceImpl.selectKmProList(kmPro);
        return getDataTable(list);
    }


    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult edit(KmPro kmPro)
    {
        if (kmPro ==null){
            return error("修改排序失败");
        }
        return toAjax(proManagerServiceImpl.updatePrettyById(kmPro));
    }

    //声明单元方法:完成查看标杆项目详情页面
    @GetMapping("/detail/{proId}")
    public String selectPro(){
        return prefix+"/detail";
    }
}
